package com.sam.designpattern.observer;

/**
 * @Author: Sam
 * @Date: 2022-08-19 14:50
 * @Description: 观察者客户端
 */
public class Client {
    public static void main(String[] args) {
        //创建一个报纸，作为被观察者
        NewsPaper subject = new NewsPaper();

        //创建阅读者，也就是观察者
        Reader reader1 = new Reader();
        reader1.setName("张三");
        Reader reader2 = new Reader();
        reader2.setName("李四");
        Reader reader3 = new Reader();
        reader3.setName("王五");

        //注册观察者
        subject.attach(reader1);
        subject.attach(reader2);
        subject.attach(reader3);

        //出版报纸
        subject.setContent("本期内容是观察者模式");
    }
}
